import { Auths, mapAuthToLabel } from '@/utils/types.d';
import { useState } from 'react';
interface AuthOptions {
  label: string;
  value: string;
  disable?: boolean;
}

export function useAuthVariable(originAuth: Auths[]) {
  const [intermin, setIntermin] = useState<boolean>(true);
  const [list, setList] = useState<Auths[]>([]);
  const [enable, setEnable] = useState<boolean>(false);
  const [checkAll, setCheckAll] = useState<boolean>(false);
  const auth: AuthOptions[] = originAuth.map((item) => ({
    label: mapAuthToLabel(item),
    value: item,
    disabled: item === Auths.READ ? false : enable,
  }));
  return {
    intermin,
    list,
    checkAll,
    auth,
    setIntermin,
    setList,
    setEnable,
    setCheckAll,
  };
}
